package com.tbit.uqbike.webmanager.controller;

import com.tbit.uqbike.object.pojo.BlackListLog;
import com.tbit.uqbike.object.view.JsonResult;
import com.tbit.uqbike.service.business.BlackListLogService;
import com.tbit.uqbike.webmanager.util.Assert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author jing
 * @date 2020/10/2813:45
 * @Description:黑名单日志
 */
@RestController
@RequestMapping(value = "/blacklistLog", produces = BaseController.MEDIA_JSON_UTF8)
public class BlackListLogController {
    @Autowired
    private BlackListLogService blackListLogService;

    /* 分页查询 */
    @RequestMapping("/queryPage")
    public JsonResult queryPage(String phone, String idNo, Integer brandId, Integer blockType, String operatorNumber,
                                @RequestParam(defaultValue = "10") Integer rowCount,
                                @RequestParam(defaultValue = "1") Integer pageNO, HttpServletRequest request) {
        Map<String, Object> params = new HashMap<>();
        Assert.notNull(brandId, "ver.accountId.notNull");

        List<BlackListLog> blackListLogs = blackListLogService.getByPhone(params, brandId, phone, idNo, operatorNumber, rowCount, pageNO);
        Integer count = blackListLogService.getCountByPhone(params, brandId, phone, idNo, operatorNumber);
        return JsonResult.ok(blackListLogs, count);

    }
}
